package com.jyh.controller.money;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.jyh.service.money.AccountService;

/**
 * 财务管理 ---平台账户管理
 * 
 * @author
 */
@Controller
@RequestMapping(value = "/account")
public class AccountController{
	private static Logger logger = Logger.getLogger(AccountController.class);
	@Autowired
	private AccountService accountService;

	/**
	 * 获取平台账户管理页面数据
	 * 
	 * @return
	 */
	@RequestMapping(value = "/account")
	public ModelAndView getAccount(HttpServletRequest request, HttpSession session) {
		try {
			logger.info("begin");
			ModelAndView mv = accountService.getAccount(request, session);
			logger.info("end");
			return mv;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("\n -------------error信息开始-------------- \n" + e
					+ "\n -----------------error信息结束------------------\n\n");
			return null;
		}
	}
	
	/**
	 * 平台账户管理页面---充值页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "/accountRecharge")
	public ModelAndView getAccountRecharge(HttpServletRequest request, HttpSession session) {
		try {
			logger.info("begin");
			ModelAndView mv = accountService.getAccountRecharge(request, session);
			logger.info("end");
			return mv;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("\n -------------error信息开始-------------- \n" + e
					+ "\n -----------------error信息结束------------------\n\n");
			return null;
		}
	}
	
	/**
	 * 平台账户管理页面---确认充值
	 * 
	 * @return
	 */
	@RequestMapping(value = "/recharge")
	public ModelAndView getRecharge(HttpServletRequest request, HttpSession session) {
		try {
			logger.info("begin");
			accountService.getRecharge(request, session);
			ModelAndView mv = accountService.getAccount(request, session);
			logger.info("end");
			return mv;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("\n -------------error信息开始-------------- \n" + e
					+ "\n -----------------error信息结束------------------\n\n");
			return null;
		}
	}
	
	
	/**
	 * 平台账户管理页面---提现页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "/accountWithdraw")
	public ModelAndView getAccountWithdraw(HttpServletRequest request, HttpSession session) {
		try {
			logger.info("begin");
			ModelAndView mv = accountService.getAccountWithdraw(request, session);
			logger.info("end");
			return mv;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("\n -------------error信息开始-------------- \n" + e
					+ "\n -----------------error信息结束------------------\n\n");
			return null;
		}
	}
	
	/**
	 * 平台账户管理页面---确认提现
	 * 
	 * @return
	 */
	@RequestMapping(value = "/withdraw")
	public ModelAndView getWithdraw(HttpServletRequest request, HttpSession session) {
		try {
			logger.info("begin");
			accountService.getWithdraw(request, session);
			ModelAndView mv = accountService.getAccount(request, session);
			logger.info("end");
			return mv;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("\n -------------error信息开始-------------- \n" + e
					+ "\n -----------------error信息结束------------------\n\n");
			return null;
		}
	}
	
	/**
	 * 平台账户管理页面---转账页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "/accountTransfer")
	public ModelAndView getAccountTransfer(HttpServletRequest request, HttpSession session) {
		try {
			logger.info("begin");
			ModelAndView mv = accountService.getAccountTransfer(request, session);
			logger.info("end");
			return mv;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("\n -------------error信息开始-------------- \n" + e
					+ "\n -----------------error信息结束------------------\n\n");
			return null;
		}
	}
	
	/**
	 * 平台账户管理页面---确认转账
	 * 
	 * @return
	 */
	@RequestMapping(value = "/transfer")
	public ModelAndView getTransfer(HttpServletRequest request, HttpSession session) {
		try {
			logger.info("begin");
			accountService.getTransfer(request, session);
			ModelAndView mv = accountService.getAccount(request, session);
			logger.info("end");
			return mv;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("\n -------------error信息开始-------------- \n" + e
					+ "\n -----------------error信息结束------------------\n\n");
			return null;
		}
	}
	
	
	/**
	 * 平台账户管理页面---记录页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "/accountRecord")
	public ModelAndView getAccountRecord(HttpServletRequest request, HttpSession session) {
		try {
			logger.info("begin");
			ModelAndView mv = accountService.getAccountRecord(request, session);
			logger.info("end");
			return mv;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("\n -------------error信息开始-------------- \n" + e
					+ "\n -----------------error信息结束------------------\n\n");
			return null;
		}
	}
}
